package com.hq.ims.data.vo;

import com.hq.authority.utils.AppUtils;
import com.hq.ims.data.config.verification.VdEdit;
import com.hq.ims.data.entity.BusInfoFeedbackDerive;
import com.hq.ims.data.vo.auth.BaseRowAuthVo;
import com.hq.utils.util.ListUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import javax.validation.constraints.NotBlank;
import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;


/**
 * @author 蒋柏平
 * @since 20241108
 */
@Mapper
public interface BusInfoFeedbackDeriveMapstruct {

    BusInfoFeedbackDeriveMapstruct INSTANCE = Mappers.getMapper(BusInfoFeedbackDeriveMapstruct.class);

    //-------------------------------- 转换VO类 --------------------------------

    @Mappings({
    })
    BusInfoFeedbackDeriveVo toBusInfoFeedbackDeriveVo(BusInfoFeedbackDerive source);

    default List<BusInfoFeedbackDeriveVo> toBusInfoFeedbackDeriveVoList(List<BusInfoFeedbackDerive> source){
        if (source == null) {
            return ListUtils.newEmptyList();
        }
        return source.stream().map(this::toBusInfoFeedbackDeriveVo).collect(Collectors.toList());
    }

    //-------------------------------- 以下为自定义类[输出对象] --------------------------------

    @ApiModel(value = "原始对象的扩展类")
    @Data
    class BusInfoFeedbackDeriveVo extends BusInfoFeedbackDerive {
        
    }

    @ApiModel(value = "行级权限对象")
    @Data
    class BusInfoFeedbackDeriveRowAuthVo extends BaseRowAuthVo {

        //自定义其它行级权限


        //构造函数
        public BusInfoFeedbackDeriveRowAuthVo(BusInfoFeedbackDerive entity){
            //当前操作用户ID
            String userId = AppUtils.getUserId();
            //是否创建者
            boolean isCreateUser = entity.getCreateUserId().equals(userId);

            //设置编辑( 是创者者 )
            super.setIsCanEdit(isCreateUser);

            //设置删除( 是创者者 )
            super.setIsCanDel(isCreateUser);
        }
        
    }


    //-------------------------------- 以下为自定义类[输入对象] --------------------------------

    @ApiModel(value = "搜索VO")
    @Data
    class PageSearchVo {

    }

    @ApiModel(value = "添加和修改对象")
    @Data
    class SaveVo {

        @NotBlank(message = "数据ID不能为空", groups = {VdEdit.class})
        @ApiModelProperty(value = "数据ID")
        private String busInfoFeedbackDeriveId;

        @ApiModelProperty(value = "经营信息反馈ID")
        private String busInfoFeedbackId;

        @ApiModelProperty(value = "经营信息ID")
        private String busiInfoId;

        @ApiModelProperty(value = "派生的经营信息ID")
        private String deriveBusiInfoId;

        @ApiModelProperty(value = "")
        private LocalDateTime createDateTime;

        @ApiModelProperty(value = "")
        private LocalDateTime updateDateTime;

        @ApiModelProperty(value = "")
        private String createUserName;

        @ApiModelProperty(value = "")
        private String updateUserName;

        @ApiModelProperty(value = "")
        private Integer version;

        @ApiModelProperty(value = "")
        private Boolean isDel;

        @ApiModelProperty(value = "")
        private String createUserId;

        @ApiModelProperty(value = "")
        private String updateUserId;

        @ApiModelProperty(value = "")
        private String orgId;



    }

    //-------------------------------- springboot验证标识 --------------------------------

}
